package com.group7.mall.common;

import com.group7.mall.bean.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

// 这个注解集成了AOP切面编程用法
@RestControllerAdvice
public class ExceptionAdaptController {

    // 指定拦截哪种异常
    @ExceptionHandler({RuntimeException.class})
    public Result runTimeException(RuntimeException e) {
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler({Exception.class})
    public Result exception(RuntimeException e) {
        e.printStackTrace();
        return Result.fail();
    }
}
